<%@page import="org.datanucleus.query.evaluator.memory.StringLengthMethodEvaluator"%>
<%@ page import="agentFree2.*,java.net.*,java.io.*,java.nio.charset.*,java.nio.*,java.util.Date,java.util.logging.Logger,java.util.regex.Pattern,java.util.regex.Matcher,javax.jdo.PersistenceManager,javax.servlet.http.*" %>
<%
	Pattern advNumberPattern = Pattern.compile("/realestate/rent-flats/longtime/[0-9]{7}/");
	URL u = new URL("http://irr.by/realestate/rent-flats/longtime/page_len5/");
	String s;

	s = ReaderFactory.readUrlData(u,"ISO-8859-1");
	//out.println(s);
	Matcher advNumberMatcher = advNumberPattern.matcher(s);
    //OPen connection to datastore.
	int iter = 0;
	URL advUrl;
	while (advNumberMatcher.find()) {
		iter++;
		String advNumberString = advNumberMatcher.group();
		//advNumberString = advNumberString.replace("rent-flats/longtime/","rooms/rent/");	
		out.println("__________________________________________________________________________"+iter+"____________________________________"+advNumberString);
		try{
			advUrl = new URL("http://purepormula.appspot.com/irr/checkAdvOnAgent.jsp?URL=http://irr.by"+advNumberString);
			out.println(advUrl);
			//out.println(ReaderFactory.readUrlData(advUrl,"ISO-8859-1"));
		}catch(Exception e){
			out.println(e.getMessage());
		}
		
		
	}
%>